﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;

public partial class ServicesSheet_SCGYPrint : System.Web.UI.Page
{
    private ReportDocument reportdoc = null;
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnPreInit(EventArgs e)
    {
        string prinid = Request.Params["printId"];
        if (prinid == null)
        {
            return;
        }   
        reportdoc = new ReportDocument();
        reportdoc.Load(Server.MapPath("SCGYReport.rpt"));
        string selectSql = @"SELECT     
                                Services_SCGY.Id,
                                Employees.EmpName, 
                                convert(varchar(4),year(Services_SCGY.UDate))+'-'+convert(varchar(2),month(Services_SCGY.UDate))+'-'+convert(varchar(2),day(Services_SCGY.UDate))  as UDate,  
                                Services_SCGY.PeopleCount, 
                                Services_SCGY.Client, 
                                Services_SCGY.Cause, 
                                Services_SCGY.Route, 
                                Services_SCGY.BeginLM,
                                Services_SCGY.EndLM, 
                                Services_SCGY.UseKil, 
                                Services_SCGY.SupExpenses, 
                                Services_SV_CarSubsidy.PerKMSubsidy, 
                                Services_SCGY.SubsidyMoney
                            FROM         
                                Services_SCGY LEFT JOIN
                                                      Employees ON Services_SCGY.EmployeeId = Employees.EmployeeID 
                                              LEFT JOIN
                                                      Services_SV_CarSubsidy ON Services_SCGY.SubsidyId = Services_SV_CarSubsidy.SubId
                                              where Services_SCGY.Id in " + prinid;

        object[] objParam = new object[2];
        objParam[0] = selectSql;
        objParam[1] = "Services_SCGY";
        object[] myRet = Srvtools.CliUtils.CallMethod("ServiceSheet", "ExecSqlByDataSet", objParam);
        DataSet ds = (DataSet)myRet[1];
        reportdoc.SetDataSource(ds);
        this.CrystalReportViewer1.ReportSource = reportdoc;

    }
}
